<template>

  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="listQuery.real_name" placeholder="客户姓名" style="width: 150px;margin-top:8px" class="filter-item" @keyup.enter.native="handleFilter" />
      <el-date-picker v-model="listQuery.date" style="width:150px" format="yyyy-MM-dd" type="datetime" placeholder="开始日期" />
      <el-date-picker v-model="listQuery.date_end" style="width:150px" format="yyyy-MM-dd" type="datetime" placeholder="结束日期" />
      <company ref="companys" />
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter" style="margin-top:8px">查询</el-button>
      <!-- <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="create" style="margin-top:8px">新增</el-button> -->
      <!-- <excelout ></excelout> -->
    </div>

    <el-table :key="tableKey" v-loading="listLoading" :data="list" :show-overflow-tooltip='true' size="mini" border fit highlight-current-row style="width: 100%;"> 
      <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
        <template slot-scope="{row}">

          <el-button  size="mini" type="primary" @click="detail(row)">
            详情
          </el-button>
          <el-button  size="mini" type="primary" @click="approval(row)">
            审批
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="车辆收回日期" prop="id" align="center" width="120">
        <template slot-scope="{row}">
          <span>{{ row.car_back_date }}</span>
        </template>
      </el-table-column>

      <el-table-column label="结清处理时间" align="center" width="120">
        <template slot-scope="{row}">
          <span>{{ row.settle_date }}</span>
        </template>
      </el-table-column>

      <el-table-column label="门店" align="center">
        <template slot-scope="{row}">
          <span>{{ row.c_name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="客户姓名" align="center">
        <template slot-scope="{row}">
          <span>{{ row.real_name }}</span>
        </template>
      </el-table-column>

      <el-table-column label="电话" class-name="status-col" width="120">
        <template slot-scope="{row}">
          {{ row.mobile}}
        </template>
          </el-table-column>
        <el-table-column label="负责人" class-name="status-col">
          <template slot-scope="{row}">
            {{ row.admin_name}}
          </template>

      </el-table-column>
      <el-table-column label="融资金额" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.total_price}}
        </template>
      </el-table-column>
      <el-table-column label="结清金额" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.settle_money}}
        </template>
      </el-table-column>
      <el-table-column label="结清类型" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.settle_type_name}}
        </template>
      </el-table-column>
      <el-table-column label="清收开支" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense0}}
        </template>
      </el-table-column>
      <el-table-column label="清收人工" class-name="status-col"  width="100">
        <template slot-scope="{row}">
           {{ row.expense8}}
        </template>
      </el-table-column>
      <el-table-column label="解押费" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense2}}
        </template>
      </el-table-column>
      <el-table-column label="过户费" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense3}}
        </template>
      </el-table-column>
      <el-table-column label="卖车" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense4}}
        </template>
      </el-table-column>
      <el-table-column label="违章" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense5}}
        </template>
      </el-table-column>
      <el-table-column label="其他费用" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense8}}
        </template>
      </el-table-column>
      <el-table-column label="运输费" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense6}}
        </template>
      </el-table-column>
      <el-table-column label="停车费" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense7}}
        </template>
      </el-table-column>
      <el-table-column label="费用合计" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.expense_money}}
        </template>
      </el-table-column>
      <el-table-column label="剩余租金" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.no_paid_money}}
        </template>
      </el-table-column>
      <el-table-column label="保底提成" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.bdtc}}
        </template>
      </el-table-column>
      <el-table-column label="违约金" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.wyj}}
        </template>
      </el-table-column>
      <el-table-column label="对客清收费" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.qsf}}
        </template>
      </el-table-column>
      <el-table-column label="优惠" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.yh}}
        </template>
      </el-table-column>
      <el-table-column label="租后结算金额" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.zhjsje}}
        </template>
      </el-table-column>
      <el-table-column label="租后提成" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.zhtc}}
        </template>
      </el-table-column>
      <el-table-column label="超期扣款" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.cqkk}}
        </template>
      </el-table-column>
      <el-table-column label="扣款" class-name="status-col" width="100">
        <template slot-scope="{row}">
           {{ row.kk}}
        </template> 
      </el-table-column>
      <el-table-column label="负责人提成" class-name="status-col"  width="100">
        <template slot-scope="{row}">
           {{ row.fzrtc}}
        </template>
      </el-table-column>
      <el-table-column label="提成清收开支总额" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.tcqskzze}}
        </template>
      </el-table-column>
      <el-table-column label="股东费用占比" class-name="status-col" width="200">
        <template slot-scope="{row}">
           {{ row.shareholderprift}}
        </template>
      </el-table-column>
      <el-table-column label="备注" class-name="status-col">
        <template slot-scope="{row}">
           {{ row.approval_status_name}}
        </template>
      </el-table-column>

      <!-- <el-table-column label="审核时间" class-name="status-col" width="900">
        <template slot-scope="{row}">
          {{ row.os}}
        </template>
          </el-table-column> -->
    

    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />

      <el-dialog title="详情" :visible.sync="detailAble" style="width:1800px;margin:auto">
      <el-form ref="dataForm" :model="other_form" label-width="120px">
        <el-row>
          <el-col :span="12">客户姓名：{{ rent.real_name }}</el-col>
          <el-col :span="12">门店：{{ rent.c_name }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">车牌号：{{ rent.plate_no }}</el-col>
          <el-col :span="12">报销金额：{{ rent.expense_money }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">结清金额：{{ rent.settle_money }}</el-col>
          <el-col :span="12">车辆回收日期：{{ rent.car_back_date }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">填报时间：{{ rent.create_time }}</el-col>
          <el-col :span="12">填报人：{{ rent.admin_name }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">车辆状态：{{ rent.car_status_name }}</el-col>
          <el-col :span="12">结清类型：{{ rent.settle_type_name }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">是否投诉： <span v-if="rent.sue==1">已投诉</span> <span v-if="rent.sue==0">未投诉</span></el-col>
          <el-col :span="12">车辆及入库资料：{{ rent.inroom_data }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">当前状态：{{ rent.real_name }}</el-col>
          <el-col :span="12">备注信息：{{ rent.desc }}</el-col>
        </el-row>
        <el-row style="margin-top: 20px;">
          <el-col :span="12">结清处理时间：{{ rent.settle_date }}</el-col>
        </el-row>
        <div  class="l_title">报销信息</div>
        <el-card class="box-card" style="margin-top: 20px;" v-for="(item,index) in rent.expense" :key="index">
          <el-row >
            <el-col :span="12">报销类型：{{ item.expense_name }}</el-col>
            <el-col :span="12">报销金额：{{ item.money }}</el-col>
          </el-row> 
          <el-row style="margin-top: 20px;">
            <el-col :span="24">图片信息</el-col>
            <el-col :span="24">
              <div ref="viewer" v-viewer="viewerOptions" class="">
                <div v-for="(img,index1) in item.att" :key="index1" class="grid-content bg-purple-light img_box">
                  <div class="hovers">{{ item.field }}</div>
                  <img :src="img.path" height="100%" width="100%">
                </div>
              </div>
            </el-col>
          </el-row> 
        </el-card>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="danger" @click="expenseSubmitApproval(4)">驳回</el-button>
        <el-button type="primary" @click="expenseSubmitApproval(3)">通过</el-button>
      </span>
    </el-dialog>
  </div>

</template>

<script>

import {
  getCustomer,expenseFinanceList,expenseSubmitApproval,approvalKK
} from '@/api/manager'
import { getThisOrderShareHolder } from '@/api/finance'
  import {
    formatDate
  } from '@/utils/formatDate.js'
  import waves from '@/directive/waves' // waves directive
  import company from '@/components/company/company.vue'
  import {
    parseTime
  } from '@/utils'
  import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  export default {
    name: 'BalanceTable',
    components: {
      Pagination,company
    },
    directives: {
      waves
    },
    filters: {
      formatDate(time) {
        time = time * 1000
        let date = new Date(time)
        return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
      }
    },
    data() {
      return {
        profitCount_form:{},
        profitCountAble:false,
        viewerOptions: true,
        detailAble:false,
        customerlist:[],
        add_form:{
          
        },
        myHeaders: {
          token: this.$store.getters.token
        },
        action: process.env.VUE_APP_BASE_API + '/backend_upload',
        fileList: [],
        createlAble:false,
        addAble:false,
        create_form:{
          expense:[],
          real_name:'',
          sue:0,
          car_status:''
        },
        tableKey: 0,
        list: [],
        total: 0,
        listLoading: true,
        listQuery: {
          page: 1,
          limit: 20,
          step:5,
          
        },
        end_profit:'',
        type_list:[],
        rent:[],
        other_form:{},
        shareholder_from: {
        order_id: '',
        datas: [
          {
            shareholder: '',
            money: '',
            percentage: '',
            benefits: ''
          }
        ]
      },
      }
    },
    created() {
      this.listLoading=false
      this.getList()
    },
    methods: {
      detail(row){
        
          this.rent = row;
          this.detailAble = true;
        
      },
      approval(row){
        let pam = {
          id:row.id,
          kk:row.kk,
        }
        this.$confirm('确定要通过扣款审批吗, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            approvalKK(pam).then(response => {
              this.$notify({
              title: '提示',
              message: 'success',
              type: 'success',
              duration: 2000,
              onClose: this.getList()
            })
          })
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '取消操作'
            });          
          });
      },
     
      handleFilter() {
        const c_id = this.$refs.companys.$data.listQuery.c_id
        this.listQuery.c_id = c_id
        this.listQuery.page = 1
        this.getList()
      },
      getList() {
        this.listLoading = true
        expenseFinanceList(this.listQuery).then(response => {
          this.list = response.data.data.data
          this.total = response.data.data.total
          setTimeout(() => {
            this.listLoading = false
          }, 1.0 * 1000)
        })
      },
      getCustomer() {
        //this.listLoading = true
        getCustomer().then(response => {
          this.customerlist = response.data
        })
      }
    }
  }
</script>

<style>
  .l_title {
    font-size: 14px;
    font-weight: 700;
    margin-top:20px
  }
  .img_box {
    width: 150px;
    height: 150px;
    margin-left: 16px;
    float: left;
    position: relative;
    margin-top: 20px;
  }
</style>
